﻿
using System.Collections.Generic;
using System.Runtime.InteropServices;

namespace Enferno.Public.Web.Models
{
    public class ProductListModel :
        ProductListCustomVariantModel<VariantModel, ProductItemModel>
        //ProductListBaseModel
        //    <ProductItemModel, FilterModel, VariantModel, ProductFileModel, ProductManufacturerModel, PriceModel,
        //        OnHandStatusModel, ParametricModel, ParametricValueModel>
    {
        
    }

    public class ProductListCustomVariantModel<TVariant, TProductItemModel> :
        ProductListBaseModel<
            TProductItemModel, 
            FilterModel, 
            TVariant, 
            ProductFileModel, 
            ProductManufacturerModel, 
            PriceModel,
            OnHandStatusModel, 
            ParametricModel, 
            ParametricValueModel>
        where TVariant : VariantBaseModel<OnHandStatusModel, PriceModel, ProductFileModel, ParametricModel, ParametricValueModel>
        where TProductItemModel: ProductItemCustomVariantModel<TVariant>
    {
        public ProductListCustomVariantModel() : base()
        {
            
        }
        
    } 

    /// <summary>
    /// The ProductListModel can be used on product list pages.
    /// </summary>
    public class ProductListBaseModel<
        TProductItemModel, 
        TFilterModel,
        TVariantModel, 
        TProductFileModel, 
        TProductManufacturerModel, 
        TPriceModel, 
        TOnHandStatusModel, 
        TParametricModel, 
        TParametricValueModel>
        where TProductItemModel: ProductItemBaseModel<TVariantModel, TProductFileModel, TProductManufacturerModel, TPriceModel, TOnHandStatusModel, TParametricModel, TParametricValueModel>
        where TFilterModel: FilterModel 
        where TVariantModel : VariantBaseModel<TOnHandStatusModel, TPriceModel, TProductFileModel, TParametricModel, TParametricValueModel>
        where TProductFileModel : ProductFileModel
        where TProductManufacturerModel : ProductManufacturerModel
        where TPriceModel : PriceModel
        where TOnHandStatusModel : OnHandStatusModel
        where TParametricModel : ParametricBaseModel<TParametricValueModel>
        where TParametricValueModel : ParametricValueModel 
    {
        public ProductListBaseModel()
        {
            Items = new List<TProductItemModel>();
            Filters = new List<TFilterModel>();
        }

        /// <summary>
        /// ListParametric can be used as parameter when listing products by parametrics. 
        /// Specify the parametric Id and set either ValueId or ValueFrom/ValueTo.
        /// ValueTo and ValueFrom can be used to specify value ranges. If no range is wanted, just specify ValueFrom.
        /// </summary>
        public class ListParametric
        {
            public int Id { get; set; }
            public int? ValueId { get; set; }
            public string ValueFrom { get; set; }
            public string ValueTo { get; set; }
        }

        /// <summary>
        /// This is the total item count regardless of filtering and paging, while Items.Count is the actual number of items returened.
        /// </summary>
        public int ItemCount { get; set; }

        public List<TProductItemModel> Items { get; set; }

        public List<TFilterModel> Filters { get; set; }
    }
}
